package days48;

import java.util.Scanner;

public class day17 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String[]strings={"3","4","5","6","7","8","9","10","J","Q","K","A","2","joker","JOKER"};
        String Line=scanner.nextLine();
        String[] strs=Line.split("-");
        String[] str1=strs[0].split(" ");
        String[] str2=strs[1].split(" ");
        if (str1[0].equals("joker")&&str1[1].equals("JOKER")){
            System.out.println("joker JOKER");
        }
        boolean k=true;
        for (int i = 0; i < str1.length-1; i++) {
            if(str1[i+1]==str1[i]){
                continue;
            }
            k=false;
        }
        if(k){
            if(str1[0].compareTo(str2[0])>0){
                System.out.println(str1);
            }else {
                System.out.println(str2);
            }
        }
    }
    public static void main1(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int count=0;
        for (int i = 2; i < n; i++) {
            if(judge(i)){
                count++;
            }
        }
        System.out.println(count);
    }

    private static boolean judge(int i) {
        int sum=1;
        for (int j = 2; j <= Math.sqrt(i); j++) {
            if(i%j==0){
                sum+=j;
                sum+=i/j;
            }
        }
        if(sum==i){
            System.out.println(i);
            return true;
        }
        return false;
    }
}
